package com.thd.springboottest.s3.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

/**
 * com.lenovo.dqm.common.utils.FileNameUtils
 * 生成文件名称 - 重复概率很低的
 * @author: wanglei62
 * @DATE: 2020/2/20 10:27
 **/
public class FileNameUtils {
    public static String createFileName(String preffix,String suffix){

        LocalDateTime localDateTime = LocalDateTime.now();
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss");
        String randomStr = UUID.randomUUID().toString().replace("-","");
        String dateTimeStr = localDateTime.format(dtf);

        String result = preffix+ "_" + dateTimeStr + "_" + randomStr + "." + suffix;
        return result;
    };
}
